(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.popup.glPostMgrViewController', glPostMgrViewController);
	glPostMgrViewController.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig' , 'authService', 'ajaxServiceFactory', 'validatorConfig', 'arithService'];
	function glPostMgrViewController($scope, $q, $uibModalInstance, Constants, dialogsModule, gridService, modalService, layoutConfig, authService, ajaxServiceFactory, validatorConfig, arithService) {
		var ctrl = this, params = $scope.$stateParams.params;
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.glPostMgrDynaparm = ctrl.dialogsModule.params.glPostMgrDynaparm || {};
		ctrl.formName = "glPostMgrForm"
		
		ctrl.init = function() {
			var gridConfigs = ctrl.layoutConfig.formConfigs.glpostmgr.gridConfigs;
			var glPostMgr = ctrl.dialogsModule.params.glPostMgr;
			if(glPostMgr){
				if (gridConfigs) {
					angular.forEach(gridConfigs, function(gridConfig, key) {
						if (gridConfig.dynamicParameter && "GLPOSTMGR" == gridConfig.dynamicParameter.category && glPostMgr != gridConfig.dynamicParameter.subCategory) {
							gridConfigs[key].active = false;
						} else if (gridConfig.dynamicParameter && "GLPOSTMGR" == gridConfig.dynamicParameter.category && glPostMgr == gridConfig.dynamicParameter.subCategory) {
							gridConfigs[key].active = true;
							gridConfigs[key].size =7;
						}
					});
				}
			}else{
				if (gridConfigs) {
					angular.forEach(gridConfigs, function(gridConfig, key) {
						gridConfigs[key].active = false;
					});
				}
			}


		};
		
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
	}
})(angular);
